package com.changgou.system.filter;

/**
 * @author : jam.chen
 * @Project : changgou_parent
 * @ClassName : UrlFilter
 * @PackageName : com.changgou.system.filter
 * @date : 2020/7/19  21:54
 * @Version : 1.0
 */

import org.springframework.cloud.gateway.filter.GatewayFilterChain;
import org.springframework.cloud.gateway.filter.GlobalFilter;
import org.springframework.core.Ordered;
import org.springframework.http.server.RequestPath;
import org.springframework.http.server.reactive.ServerHttpRequest;
import org.springframework.stereotype.Component;
import org.springframework.web.server.ServerWebExchange;
import reactor.core.publisher.Mono;

/**
 * 获取客户端的方位url
 */

@Component
public class UrlFilter implements GlobalFilter, Ordered {

    @Override
    public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain) {
        System.out.println("我们经过了第二个过滤器");
        ServerHttpRequest request = exchange.getRequest();
        RequestPath path = request.getPath();
        System.out.println("Path:"+path);

        return chain.filter(exchange);
    }

    @Override
    public int getOrder() {
        return 2;
    }
}
